package org.come.control;

import java.math.BigDecimal;

import org.come.Frame.ZhuFrame;
import org.come.action.NpcMenuAction;
import org.come.entity.Goodstable;
import org.come.mouslisten.GoodsMouslisten;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.UserData;

import com.tool.role.RoleData;

public class GiveAHandcontrol implements NpcMenuAction {

	@Override
	public void menuControl(String type) {
		if("我来助你一孵之力（需提交一个物品）".equals(type)){//助力孵蛋
			// 判断是否有灵兽蛋精华
			Goodstable goodstable = null;
			for (int i = 0; i < GoodsListFromServerUntil.getGoodslist().length; i++) {
				if(GoodsListFromServerUntil.getGoodslist()[i] == null) {
                    continue;
                }
				if(GoodsListFromServerUntil.getGoodslist()[i].getType() == 2327){//2327灵兽蛋精华
					goodstable = GoodsListFromServerUntil.getGoodslist()[i];
					break;
				}
			}
			if(goodstable == null) {
				ZhuFrame.getZhuJpanel().addPrompt("没有灵兽蛋精华");
				return;
			}
			// 消耗灵兽蛋精华加孵化值
			goodstable.setUsetime(0);
			GoodsMouslisten.gooduse(goodstable,1);
			// 前端删除
			GoodsListFromServerUntil.Deletebiaoid(goodstable.getRgid());
			// 发送服务器添加孵化值
			SendMessageUntil.toServer(Agreement.getAgreement().HatchaddAgreement(""));
		}else if("直接打开".equals(type)){//直接打开
			Goodstable goodstable = null;
			for (int i = 0; i < GoodsListFromServerUntil.getGoodslist().length; i++) {
				if(GoodsListFromServerUntil.getGoodslist()[i] == null) {
                    continue;
                }
				if(GoodsListFromServerUntil.getGoodslist()[i].getType() == 506){
					goodstable = GoodsListFromServerUntil.getGoodslist()[i];
					break;
				}
			}
			if(goodstable == null) {
                return;
            }
//			LuckDraw.choujiang(goodstable,"350",goodstable.getGoodsname());
		}else if("祈福（500W金币）".equals(type)){//祈福（500W金币）
			//判断有没有500W金币
			if(RoleData.getRoleData().getLoginResult().getGold().longValue() < 5000000){
				ZhuFrame.getZhuJpanel().addPrompt("金币不足");
				return;
			}
			Goodstable goodstable = null;
			for (int i = 0; i < GoodsListFromServerUntil.getGoodslist().length; i++) {
				if(GoodsListFromServerUntil.getGoodslist()[i] == null) {
                    continue;
                }
				if(GoodsListFromServerUntil.getGoodslist()[i].getType() == 506){
					goodstable = GoodsListFromServerUntil.getGoodslist()[i];
					break;
				}
			}
			if(goodstable == null) {
                return;
            }
//			LuckDraw.choujiang(goodstable,"351",goodstable.getGoodsname());
			//扣除金币
			UserData.uptael(new BigDecimal(5000000).longValue());
		}
	}

}
